<?php
defined('BY_JYA') or exit('error');
$return=array();
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return['account']=$_SESSION['account'];
$return['extradata']=array();
if($_RQ['op']=='list'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>1);
	if($_RQ['title']){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	$orderby=array();
	$_RQ['page'] = $_RQ['page'] ? $_RQ['page'] : 1;
	$pindex = max(1, intval($_RQ['page']));
	if(intval($_RQ['num'])){
		$psize = intval($_RQ['num']);
	}else{
		$psize = 10;
	}
	$total='';
	$list=pdo_getslice('jy_workliu_liuimg',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['images']=json_decode($item['images'],true);
			$item['image']=tomedia($item['images'][0]);
			$item['createtime']=date('Y/m/d H:i:s',$item['createtime']);
			$item['url']=custom_url('jy_workliu/liuimg/detail/id='.$item['id'],true);
		}
	}
	$group_id = intval($_RQ['group_id']);
	$sharelink='jy_workliu/liuimg//fromuser='.$_SESSION['uid'];
	$return['sharedata']=array(
			'title'=>'流程图 -'.$_SESSION['account']['title'],
			'desc'=>$_SESSION['account']['title'].'-流程图列表',
			'link'=>custom_url($sharelink,true)
	);
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['list']=$list?$list:array();
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	set_html('title','流程图列表-'.$_SESSION['account']['title']);
	exi($return);
}
if($_RQ['op']=='detail'){
	//刷新阅读次数
	$id=intval($_RQ['id']);
	$item=pdo_get('jy_workliu_liuimg',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
	if(!$item){
		exi('指定流程图不存在！','error','list');
	}
	$item['images']=json_decode($item['images'],true);
	$item['image']=tomedia($item['images'][0]);
	$item['createtime']=date('Y/m/d H:i:s',$item['createtime']);
	$item['url']=custom_url('jy_workliu/liuimg/detail/id='.$item['id'],true);
	$return['sharedata']=array(
			'title'=>$item['title'] . '-' . $_SESSION['account']['title'],
			'desc'=>$item['title'].'-流程图',
			'link'=>$item['url'],
			'imgUrl'=>$item['image']
	);
	$return['item']=$item;
	set_html('title',$return['item']['title']);
	exi($return);
}
